﻿using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;

namespace Inventorycount.Common
{

        public class GlobalExceptionFilter : IExceptionFilter
        {
            private readonly ILogger<GlobalExceptionFilter> logger;
            public GlobalExceptionFilter(ILogger<GlobalExceptionFilter> logger)
            {
                this.logger = logger;
            }
            public void OnException(ExceptionContext context)
            {
                logger.LogError("发生全局异常：" + context.Exception.Message);
                context.ExceptionHandled = true;
            }
        }
    }

